home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / text / edit / vim60rt.lha / Vim / vim60 / syntax / ptcap.vim < prev    next >
Encoding:
Text File  |  2001-04-29  |  4.3 KB  |  107 lines

  1. " Vim syntax file
  2. " Language:    printcap/termcap database
  3. " Maintainer:    Haakon Riiser <haakon@riiser.net>
  4. " Last Change:    2001 Apr 25
  5.  
  6. " For version 5.x: Clear all syntax items
  7. " For version 6.x: Quit when a syntax file was already loaded
  8. if version < 600
  9.     syn clear
  10. elseif exists("b:current_syntax")
  11.     finish
  12. endif
  13.  
  14. " Since I only highlight based on the structure of the databases, not
  15. " specific keywords, case sensitivity isn't required
  16. syn case ignore
  17.  
  18. " Since everything that is not caught by the syntax patterns is assumed
  19. " to be an error, we start parsing 20 lines up, unless something else
  20. " is specified
  21. if exists("ptcap_minlines")
  22.     exe "syn sync lines=".ptcap_minlines
  23. else
  24.     syn sync lines=20
  25. endif
  26.  
  27. " Highlight everything that isn't caught by the rules as errors,
  28. " except blank lines
  29. syn match ptcapError        "^.*\S.*$"
  30.  
  31. syn match ptcapLeadBlank    "^\s\+" contained
  32.  
  33. " `:' and `|' are delimiters for fields and names, and should not be
  34. " highlighted.    Hence, they are linked to `NONE'
  35. syn match ptcapDelimiter    "[:|]" contained
  36.  
  37. " Escaped characters receive special highlighting
  38. syn match ptcapEscapedChar  "\\." contained
  39. syn match ptcapEscapedChar  "\^." contained
  40. syn match ptcapEscapedChar  "\\\o\{3}" contained
  41.  
  42. " A backslash at the end of a line will suppress the newline
  43. syn match ptcapLineCont        "\\$" contained
  44.  
  45. " A number follows the same rules as an integer in C
  46. syn match ptcapNumber        "#\(+\|-\)\=\d\+"lc=1 contained
  47. syn match ptcapNumberError  "#\d*[^[:digit:]:\\]"lc=1 contained
  48. syn match ptcapNumber        "#0x\x\{1,8}"lc=1 contained
  49. syn match ptcapNumberError  "#0x\X"me=e-1,lc=1 contained
  50. syn match ptcapNumberError  "#0x\x\{9}"lc=1 contained
  51. syn match ptcapNumberError  "#0x\x*[^[:xdigit:]:\\]"lc=1 contained
  52.  
  53. " The `@' operator clears a flag (i.e., sets it to zero)
  54. " The `#' operator assigns a following number to the flag
  55. " The `=' operator assigns a string to the preceding flag
  56. syn match ptcapOperator        "[@#=]" contained
  57.  
  58. " Some terminal capabilites have special names like `#5' and `@1', and we
  59. " need special rules to match these properly
  60. syn match ptcapSpecialCap   "\W[#@]\d" contains=ptcapDelimiter contained
  61.  
  62. " If editing a termcap file, an entry in the database is terminated by
  63. " a (non-escaped) newline.  Otherwise, it is terminated by a line which
  64. " does not start with a colon (:)
  65. if exists("b:ptcap_type") && b:ptcap_type[0] == 't'
  66.     syn region ptcapEntry   start="^\s*[^[:space:]:]" end="[^\\]\(\\\\\)*$" end="^$" contains=ptcapNames,ptcapField,ptcapLeadBlank keepend
  67. else
  68.     syn region ptcapEntry   start="^\s*[^[:space:]:]"me=e-1 end="^\s*[^[:space:]:#]"me=e-1 contains=ptcapNames,ptcapField,ptcapLeadBlank,ptcapComment
  69. endif
  70. syn region ptcapNames        start="^\s*[^[:space:]:]" skip="[^\\]\(\\\\\)*\\:" end=":"me=e-1 contains=ptcapDelimiter,ptcapEscapedChar,ptcapLineCont,ptcapLeadBlank,ptcapComment keepend contained
  71. syn region ptcapField        start=":" skip="[^\\]\(\\\\\)*\\$" end="[^\\]\(\\\\\)*:"me=e-1 end="$" contains=ptcapDelimiter,ptcapString,ptcapNumber,ptcapNumberError,ptcapOperator,ptcapLineCont,ptcapSpecialCap,ptcapLeadBlank,ptcapComment keepend contained
  72. syn region ptcapString        matchgroup=ptcapOperator start="=" skip="[^\\]\(\\\\\)*\\:" matchgroup=ptcapDelimiter end=":"me=e-1 matchgroup=NONE end="[^\\]\(\\\\\)*[^\\]$" end="^$" contains=ptcapEscapedChar,ptcapLineCont keepend contained
  73. syn region ptcapComment        start="^\s*#" end="$" contains=ptcapLeadBlank
  74.  
  75. if version >= 508 || !exists("did_ptcap_syntax_inits")
  76.     if version < 508
  77.     let did_ptcap_syntax_inits = 1
  78.     command -nargs=+ HiLink hi link <args>
  79.     else
  80.     command -nargs=+ HiLink hi def link <args>
  81.     endif
  82.  
  83.     HiLink ptcapComment        Comment
  84.     HiLink ptcapDelimiter    Delimiter
  85.     " The highlighting of "ptcapEntry" should always be overridden by
  86.     " its contents, so I use Todo highlighting to indicate that there
  87.     " is work to be done with the syntax file if you can see it :-)
  88.     HiLink ptcapEntry        Todo
  89.     HiLink ptcapError        Error
  90.     HiLink ptcapEscapedChar    SpecialChar
  91.     HiLink ptcapField        Type
  92.     HiLink ptcapLeadBlank    NONE
  93.     HiLink ptcapLineCont    Special
  94.     HiLink ptcapNames        Label
  95.     HiLink ptcapNumber        NONE
  96.     HiLink ptcapNumberError    Error
  97.     HiLink ptcapOperator    Operator
  98.     HiLink ptcapSpecialCap    Type
  99.     HiLink ptcapString        NONE
  100.  
  101.     delcommand HiLink
  102. endif
  103.  
  104. let b:current_syntax = "ptcap"
  105.  
  106. " vim: sts=4 sw=4 ts=8
  107.